<template>
  <div>
    <goodList
      v-for="(item, index) in goodsArr"
      :key="index"
      :obj="item"
    ></goodList>
    <span>ALL Number:{{ allNum }}</span>
  </div>
</template>

<script>
import goodList from "./components/11月12日练习5组件.vue";

export default {
  components: {
    goodList,
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },

  computed: {
    allNum() {
      return this.goodsArr.reduce((sum, item) => (sum += item.count), 0);
    },
  },

  watch: {},
};
</script>

<style>
</style>